﻿using MVCManage.Api.Models;
using MVCManage.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace MVCManage.Api.Controllers
{
    public class HJQ_sales_reportController : ApiController
    {
        // GET: api/HJQ_sales_report
        public ResultPageList<HJQ_sales_reportDto> Get(int page, int limit, string SlalasName = "", string ProductName = "", string SalesDate = "", string orderType="")
        {
    
            HJQ_sales_reportBLL bll = new HJQ_sales_reportBLL();
            ResultPageList<HJQ_sales_reportDto> result = new ResultPageList<HJQ_sales_reportDto>();

            int count = 0;
            var dd=  bll.page(page,limit, out count, SlalasName,ProductName, SalesDate,orderType);
            var list = from a in dd
                       select new HJQ_sales_reportDto()
                       {
                           SalesID = a.SalesID,
                           SalesDate = a.SalesDate,
                           CreateTime = (DateTime)a.CreateTime,
                           Operator = a.Operator,
                           OrderType = a.OrderType,
                           ProductName = a.ProductName,
                           Quantity = a.Quantity,
                           SalesAmount = (decimal)a.SalesAmount,
                           Specification = a.Specification,
                           StoreName = a.HJQ_store_info.shopName,
                           UnitPrice = a.UnitPrice,
                           StoreID = a.SalesID
                       };
            count = dd.Count();
            result.code = dd.Count() > 0 ? 1 : 0;
            result.msg = dd.Count() > 0 ? "ok" :"error";
            result.data = list.ToList(); 
             return result;
        }

        // GET: api/HJQ_sales_report/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/HJQ_sales_report
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/HJQ_sales_report/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/HJQ_sales_report/5
        public void Delete(int id)
        {
        }
    }
}
